<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<link href="${base}/static/css/user.css" type="text/css" rel="stylesheet" />
	<link rel="stylesheet" href="${base}/static/login/css/style.css"/>
	<title>login</title>
</head>
<body class="body_bj" style="height: 20000px">
<div class="login-box ">
	<form action="${base}/singIn" id="adminform" method="post">
		<label class="form-inline">
			<div class="form-inline-font">
				用户名 :
			</div>
			<div class="form-inline-input">
				<input type="text" name="userName" />
			</div>
		</label>
		<label class="form-inline">
			<div class="form-inline-font">
				密码 :
			</div>
			<div class="form-inline-input">
				<input type="password" name="passWord" />
			</div>
		</label>
		<label class="form-inline">
			<div class="form-inline-font">
				验证 :
			</div>
			<div class="form-inline-input">
				<div class="code-box" id="code-box">
					<input type="text" name="code" class="code-input" />
					<p></p>
					<span>>>></span>
				</div>
			</div>
		</label>

		<div class="login-btn">
			<div class="user-btn-link">
				<!--<a href="">找回密码？</a>-->
			</div>
			<button type="button" id="sinIn" style="">登录</button>
		</div>
	</form>
</div>
</body>
<script src="${base}/static/js/login.js"></script>
<script type="text/javascript" src="${base}/static/layui/jquery.min.js"></script>
<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
<script type="text/javascript" src="${base}/static/js/jquery.form.js"></script>
<script type="text/javascript" src="${base}/static/js/util.js"></script>
<script>

    window.addEventListener('load',function(){

        //code是后台传入的验证字符串
        var code = "jsaidaisd656",
            codeFn = new moveCode(code);

        //获取当前的code值
        console.log(codeFn.getCode());

        //改变code值
        //code = '46asd546as5';
        //codeFn.setCode(code);

        //重置为初始状态
        //codeFn.resetCode();

        $("#sinIn").click(function() {
            if(!ff){
                 layer.msg("请先滑动滑块进行验证！");
                 return;
             }
            $("#adminform").ajaxSubmit({
                clearForm: false,
                dataType: "JSON",
                success: function(data) {
                    if(data.code==200){
                        layer.msg('登录成功！',{time: 2000});
						window.location.href="${base}/index/index";
                    }else if(data.code==304){
						ff=false;
						codeFn.resetCode();
						layer.msg(data.message,{time: 2000});
					}else{
                        ff=false;
                        codeFn.resetCode();
                        layer.msg(data.message,{time: 2000});
                    }
                },
                error: function(){
                    ff=false;
                    codeFn.resetCode();
                    layer.msg('请求失败！',{time: 1000});
                }
            });
        });
    });
    layui.use(['jquery','form','upload','layer'], function(){
        var $ = layui.jquery
            ,layer = layui.layer
            ,form = layui.form();})
</script>
</html>